#version 300 es
#extension GL_OES_EGL_image_external_essl3 : require
precision highp float;
uniform samplerExternalOES s_TextureMap;
uniform float uValue;
uniform vec2 iResolution;
in vec2 texCoord;
out vec4 outColor;
const float OFFSET_LEVEL = 0.15;
const float SCALE_LEVEL = 4.0;

vec2 scale(vec2 uv, float level)
{
    vec2 center = vec2(0.5, 0.5);
    vec2 newTexCoord = uv.xy;
    newTexCoord -= center;
    newTexCoord = newTexCoord / level;
    newTexCoord += center;
    return newTexCoord;
}
void main()
{
    if(OFFSET_LEVEL < texCoord.x && texCoord.x < (1.0 - OFFSET_LEVEL)
    && OFFSET_LEVEL < texCoord.y && texCoord.y < (1.0 - OFFSET_LEVEL))
    {
        //将原图下采样到指定区域中
        vec2 newTexCoord = texCoord;
        newTexCoord -= OFFSET_LEVEL;
        newTexCoord = newTexCoord / (1.0 - 2.0 * OFFSET_LEVEL);
        outColor = texture(s_TextureMap,newTexCoord);
    }
    else
    {
        //原纹理坐标缩放之后再进行采样
        outColor = texture(s_TextureMap,scale(texCoord, SCALE_LEVEL));
    }
}